package com.itheima.blog.auth.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.itheima.blog.auth.entity.AdminUser;
import com.itheima.blog.auth.entity.WebUser;
import com.itheima.blog.auth.service.WebUserService;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/auth/webUser")
@RequiredArgsConstructor
public class WebUserController {
    private final WebUserService webUserService;

    @ApiOperation("通过id得到webUser")
    @GetMapping("/{id}")
    public WebUser getAdminUserById(@PathVariable(value = "id")Integer id){
        WebUser user = webUserService.getById(id);
        return user;
    }

    @ApiOperation("通过name得到webUser")
    @PostMapping("/{name}")
    public WebUser getAdminUserByName(@PathVariable(value = "name")String name){
        LambdaQueryWrapper<WebUser> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(WebUser::getName,name);
        WebUser user = webUserService.getOne(lambdaQueryWrapper);
        return user;
    }
}
